package BanyuanClub.Study.Day0309.双重锁;

public class DoubleCheck {

    //保证该变量的线程可见性和防止指令重排
    private volatile static DoubleCheck doubleCheck;
    private DoubleCheck(){

    }
    private DoubleCheck getInstance() {
        if (null == doubleCheck) {
            synchronized (DoubleCheck.class) {
                if (null == doubleCheck) {
                    doubleCheck = new DoubleCheck();
                }
            }
        }
        return doubleCheck;
    }
}
